From a755c7b1ab8db6e0e0a5b363e7d7a23fcc52e648 Mon Sep 17 00:00:00 2001 From: Jeroen van der Heijden Date: Wed, 26 Feb 2020 14:28:53 +0100 Subject: [PATCH] fixed error logging while creating shards --- include/siri/version.h | 4 ++-- src/siri/db/shard.c | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/siri/version.h b/include/siri/version.h index 3d1e4e8b..808a7179 100644 --- a/include/siri/version.h +++ b/include/siri/version.h @@ -6,7 +6,7 @@ #define SIRIDB_VERSION_MAJOR 2 #define SIRIDB_VERSION_MINOR 0 -#define SIRIDB_VERSION_PATCH 35 +#define SIRIDB_VERSION_PATCH 36 /* * Use SIRIDB_VERSION_PRE_RELEASE for alpha release versions. @@ -15,7 +15,7 @@ * Note that debian alpha packages should use versions like this: * 2.0.34-0alpha0 */ -#define SIRIDB_VERSION_PRE_RELEASE "" +#define SIRIDB_VERSION_PRE_RELEASE "-alpha-0" #ifndef NDEBUG #define SIRIDB_VERSION_BUILD_RELEASE "+debug" diff --git a/src/siri/db/shard.c b/src/siri/db/shard.c index fbb401a0..c0669f96 100644 --- a/src/siri/db/shard.c +++ b/src/siri/db/shard.c @@ -320,8 +320,8 @@ siridb_shard_t * siridb_shard_create( FILE * fp; if (SHARD_init_fn(siridb, shard) < 0) { - ERR_ALLOC siridb_shard_decref(shard); + ERR_ALLOC return NULL; } @@ -334,9 +334,11 @@ siridb_shard_t * siridb_shard_create( if ((fp = fopen(shard->fn, "w")) == NULL) { - ERR_FILE + char buf[1024]; + log_critical("Cannot create shard file: '%s' (%s)", + shard->fn, strerror_r(errno, buf, 1024)); siridb_shard_decref(shard); - log_critical("Cannot create shard file: '%s'", shard->fn); + ERR_FILE return NULL; } @@ -356,18 +358,22 @@ siridb_shard_t * siridb_shard_create( fputc(siridb->time->precision, fp) == EOF || fputc(shard->flags, fp) == EOF) { - ERR_FILE + char buf[1024]; + log_critical("Cannot write to shard file: '%s' (%s)", + shard->fn, strerror_r(errno, buf, 1024)); fclose(fp); siridb_shard_decref(shard); - log_critical("Cannot write to shard file: '%s'", shard->fn); + ERR_FILE return NULL; } if (fclose(fp)) { - ERR_FILE + char buf[1024]; + log_critical("Cannot close shard file: '%s' (%s)", + shard->fn, strerror_r(errno, buf, 1024)); siridb_shard_decref(shard); - log_critical("Cannot close shard file: '%s'", shard->fn); + ERR_FILE return NULL; } -- 2.30.2